package com.example.demo.controller;

import com.alibaba.fastjson.JSON;
import com.example.demo.pojo.Backgrounduser;
import com.example.demo.pojo.Repertorygoods;
import com.example.demo.pojo.Warehouse;
import com.example.demo.service.RepertorygoodsService;
import com.example.demo.service.WarehouseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

@Controller
@Api(value = "修改商品信息",tags = "修改商品信息")
public class RepertorygoodsController {

    @Autowired
    private WarehouseService warehouseService;
    @Resource
    private RepertorygoodsService repertorygoodsService;
    @Autowired
    private WarehouseController warehouseController;
    @RequestMapping(value = "/updateWarehousegoods",method = RequestMethod.GET)
    @ApiOperation("修改仓库商品信息")
    @ApiImplicitParams({
                        @ApiImplicitParam(name = "iss",value = "是否补货（0为否，1为是）"),
                        @ApiImplicitParam(name = "stock",value = "库存")
    })
    public String update(Repertorygoods record, HttpSession session,Model model){
        System.out.println("我是补货状态==========="+record.getIss());
        Backgrounduser backgrounduser= (Backgrounduser) session.getAttribute("houtaiUser");
        Warehouse warehouse=warehouseService.selectByUserId(backgrounduser.getBackgrounduserid());
        record.setRepertoryid(warehouse.getRepertoryid());
        //修改
        repertorygoodsService.update(record);
        warehouseController.selectUserWarehouse(session,model);
        return "wode";
    }
}
